public class Book extends Item{
    public String type;

    @Override
    public String toString() {
        return "书名："+this.getName()+"，类型："+type+"，单价："+this.getPrice()+"元"+"，数量"+this.getNumber()+"本";
    }
    public Book(String name,double price,int number,String type){
        super(name,price,number);
        this.type=type;
    }

    public String getType() {
        return type;
    }

    @Override
    public boolean equals(Object obj) {
        try {
            Book book = (Book) obj;
            return super.equals(book) && this.type.equals(book.getType());
        }catch (ClassCastException e){
            return false;
        }
    }
}
